package com.ghsc.ghxc.jsb.ui.live.activity

import androidx.lifecycle.MutableLiveData
import com.cn.appcore.base.BaseViewModel
import com.cn.appcore.ext.executeResponse
import com.cn.appcore.http.bean.BaseResponse
import com.ghsc.ghxc.jsb.api.ApiMarket
import com.ghsc.ghxc.jsb.ui.message.bean.ChatDataResult
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
/**
 * 项目：GuoHuaJsb
 * 包名：com.ghsc.ghxc.jsb.ui.live.activity
 * 类名：ShareListViewModel
 * 创建时间：2024/5/11 15:12
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class ShareListViewModel : BaseViewModel() {




    /** 好友列表 **/
    var onFriendListData = MutableLiveData<BaseResponse<ChatDataResult>>()
    fun onFriendListMethod(paras: String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onFriendListData(paras) }
            executeResponse(
                response,
                { onFriendListData.value = response },
                { againLoginMsg.value = response.msg }
            ) { errorMsg.value = response.msg }
        }
    }

    /**  我的群聊 **/
    var onMyGroupListData = MutableLiveData<BaseResponse<ChatDataResult>>()
    fun onMyGroupListMethod(paras: String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onMyGroupListData(paras) }
            executeResponse(
                response,
                { onMyGroupListData.value = response },
                { againLoginMsg.value = response.msg }
            ) { errorMsg.value = response.msg }
        }
    }
}